package com.campus.controller;

import com.campus.entry.Course;
import com.campus.exception.BusinessException;
import com.campus.response.ResponseResult;
import com.campus.response.ResultCode;
import com.campus.service.CourseService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/course")
public class CourseController {
    @Autowired
    private CourseService courseService;
    @PostMapping("/save")
    public ResponseResult<Object> createCourse(@RequestBody Course course){
        if (course.getCourseName()==null||course.getClassId()==null||course.getActivityId()==null||course.getTeacherId()==null){
            throw new BusinessException(ResultCode.ERROR);
        }
        courseService.createCourse(course);
        return new  ResponseResult<>(ResultCode.ALL_SUCCESS,null);
    }
}
